-
Notifications
You must be signed in to change notification settings - Fork 183
[CIR] Backport TargetAddressSpaceAttr and Support both existing Lang AS and target AS attributes in pointer types and Global Ops
#1986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CIR] Backport TargetAddressSpaceAttr and Support both existing Lang AS and target AS attributes in pointer types and Global Ops
#1986
Conversation
TargetAddressSpaceAttr and Support both existing AS and target AS attributes in pointer types and Global Ops
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
TargetAddressSpaceAttr and Support both existing AS and target AS attributes in pointer types and Global OpsTargetAddressSpaceAttr and Support both existing Lang AS and target AS attributes in pointer types and Global Ops
|
I like the overall direction, thanks for taking the time to improve the holistic approach. One nit is to perhaps rename (cc @koparasy) |
I don’t have a strong objection to the implementation itself — the patch is clear and seems consistent with the upstream direction. My only hesitation is around the conceptual cost of introducing two separate address-space attributes. Address spaces are already a tricky area, and users can also influence them via language-level attributes, so reasoning about them tends to get complicated quickly. Do we have a long-term plan for how |
Hey :) thanks for the comment, we initially had laid down support for it to be unified as it is currently down here in the incubator.
The decision to split both attributes came from feedback from one of the mantainers of the core mlir dialects. llvm/llvm-project#161028 (comment) (I'd suggest thoroughly looking at the discussion for full context). Our ultimate goal is to align with other upstream dialects, specifically the ptr dialect and how it attaches memory spaces to it. I think It is fair for both of them to remain distinct in CIR at least. They would converge on the lowering stage as LLVM ir can only represent numeric address spaces. However, I think @xlauko and @andykaylor have more experience designing dialects and at the end — might have a better answer for you. |
Just want to point out that splitting is fine but it shouldn't come with the cost of code readability, having two attributes is super confusing (specially given the names aren't helping here). We should either go for the interface right away (unless there are good reasons to wait a bit more) or rename them a bit (like I suggested in the first comment) + share some of the properties for the sake of clear interfaces (passing the base around). |
I understand. Got a clear way forward now, thanks a lot for the pointers ^^ |
|
Okay, I hope the diff in this patch is not too intimidating :D I've addressed the naming (Clang -> Lang) and Implemented Regarding the implementations of each interface method, I think we can defer this for a later PR. I'm still not sure where these would fit into, I assume we would couple that with the verifiers on top of PointerType, but that's just my guess. Will fix conflicts once approved. |
bcardosolopes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM after some nits
…guage(clang) and target address-space attributes in pointer types
…lt AS and Correct test asm format
1dc9029 to
115c9f7
Compare
Bringing the changes we performed at: llvm/llvm-project#161028 down to the incubator isn't as straight-forward as I though. Therefore — this PR might be a bit long but hopefully not too complicated, bare with me :)
The main purpose of this is to bring the recent upstreamed
TargetAddressSpaceAttrand couple it withPointerTypeandGlobalOp. The main challenge is that this collides with the already implemented infrastructure related to AS that revolves around our unified enum approach (That handles numeric and lang AS). My main rationale here is that we let our new attribute to coexist with the already existingcir::AddressSpaceAttr(renamed now). so that we don't break any tests related to offload-type languages.Considering the above what I'm essentially doing is:
TargetAddressSpaceAttrhandle numeric target AS as it is done upstream.AddressSpaceAttrtoLangAdddressSpaceAttr.MemorySpaceAttrInterfacefor lang and target AS.LangAddressSpaceAttr(which handles an enum) will handle language/clang specific AS (CUDA, OpenCL, etc..) it will no longer handle target as it used to!PointerTypeand globalOps will hold aMemorySpaceAttrInterface. Similar to the upstream ptr type in the ptr dialect.lang_address_space(n)/clang_address_space(x).MemorySpaceAttrInterfaceattribute.